package edu.gyc.homework.ioencode;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class PaperFactory {
    private List<Question> questionList = new ArrayList<>();

    public void readQuestions() {
        Scanner scanner = new Scanner(System.in);
        for (int i = 1; i <= 5; i++) {
            System.out.println("请输入数学四则远算问题"+i+": ");
            String content=scanner.nextLine();
            System.out.println("请输入问题"+i+"的答案：");
            int answer = Integer.parseInt(scanner.nextLine());
            Question question = new Question(i, content, answer);
            questionList.add(question);
        }
        System.out.println("你出的试题如下：");
        for (Question q : questionList) {
            System.out.println(q);
        }
        questionList.clear();
    }

    public void storePaper() {
        ObjectOutputStream oos=null;

            try {
                oos = new ObjectOutputStream(new FileOutputStream("d:/st.st"));
                oos.writeObject(questionList);
                oos.close();
                System.out.println("试题存储完毕，请查查看d:/st.st");

            } catch (Exception e) {
                e.printStackTrace();
            }

    }


    public void jm() {
        PaperUtil.jm("d:/st.st","d:/paper.st");
    }
    public static void main(String[] args) {
        PaperFactory paperFactory =new PaperFactory();
       // paperFactory.readQuestions();
      //  paperFactory.storePaper();
        paperFactory.jm();

    }
}
